package com.lsh;

import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author ：LiuShihao
 * @date ：Created in 2020/8/19 2:14 下午
 * @desc ：
 */
//@Component
public class SpringBootTask {
    private static Boolean isRun = false;

    @Scheduled(cron = "*/5 * * * * ?")
    public void execute() {
        if (isRun){
            return;
        }
        isRun = true;
        System.out.println("定时任务0执行："+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss")));
        isRun = false;
    }
}
